/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import BD.MySql;
import Clases.Responsable;
import Clases.Tarea;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 *
 * @author angelo
 */
public class DAOTarea {

    public static boolean modificarTarea(Tarea tarea) {
        return false;
    }

    public static boolean cargarTarea(Tarea tarea) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH/mm");
        String date = sdf.format(tarea.getVencimiento());
        String sql = "INSERT INTO Tarea(Titulo, Texto, Prioridad, Vencimiento,Completado,Id_Responsable,Id_Categoria) VALUES "
                + "(\"" + tarea.getTitulo() + "\",\"" + tarea.getTexto() + "\",\"" + tarea.getPrioridad() + "\",\""
                + date + "\",\"" + tarea.getCompletado() + "\",\"" + tarea.getId_Responsable() + "\",\""
                + tarea.getId_Categoria()
                + "\")";
        MySql mySql = new MySql();
        if (mySql.executeUpdate(sql) == 0) {
            return false;
        } else {
            return true;
        }

    }

    public static boolean eliminarTarea(Tarea tarea) {
        return false;
    }

    public static boolean reasignarResponsableTarea(Responsable responsable, Tarea tarea) {
        return false;
    }

    public static boolean cambiarEstadoTarea(Tarea tarea) {
        return false;
    }

    public static List<Tarea> getTarea() {
        String sql = "SELECT * FROM Tarea";
        MySql<Tarea> mySql = new MySql<>();
        List<Tarea> lista = mySql.executeQuery(sql, Tarea.class);
        return lista;
    }
}
